import { defaultHandler } from '@/utils/request';
import { zmlist } from '@api/zm';
import Paging from '@/utils/paging';
import Taro from '@tarojs/taro';

const initialPaging = Paging.initialValue();

export default {
  namespaced: true,
  state: {
    zmlist: [],
    index: 0,
  },
  mutations: {
    clearList(state) {
      state.zmlist = [];
    },
    list(state, data) {
      state.index += 1;

      if (state.index > 4) {
        state.index = 1;
        state.zmlist = [];
      }
      state.zmlist = [...state.zmlist, ...data.data];
     
    },
  },
  actions: {
    //不要问我,为什么这样写,亮哥留下来的坑
   async getZmlist({ commit }, params) {
    let  data= await  zmlist({zmtype: 4 })
    commit('list', data);
      data= await  zmlist({zmtype: 3 })
    commit('list', data);
      data= await  zmlist({zmtype: 2 })
    commit('list', data);
      data= await  zmlist({zmtype: 1 })
    commit('list', data);
     
  },
}
};
